#include <stdio.h>
#include <stdlib.h>
#include "treefun.h"

tree_node * creattree(void)
{
	tree_node *H=(tree_node *)malloc(sizeof(tree_node));
	H->data=1;

	H->lchild=(tree_node *)malloc(sizeof(tree_node));
	H->lchild->data=2;

	H->rchild=(tree_node *)malloc(sizeof(tree_node));
	H->rchild->data=3;

	H->lchild->lchild=(tree_node *)malloc(sizeof(tree_node));
	H->lchild->lchild->data=4;
	H->lchild->lchild->lchild==NULL;
	H->lchild->lchild->rchild==NULL;

	H->lchild->rchild=(tree_node *)malloc(sizeof(tree_node));
	H->lchild->rchild->data=5;
	H->lchild->rchild->lchild==NULL;
	H->lchild->rchild->rchild==NULL;

	H->rchild->lchild=(tree_node *)malloc(sizeof(tree_node));
	H->rchild->lchild->data=6;
	H->rchild->lchild->lchild==NULL;
	H->rchild->lchild->rchild==NULL;

	H->rchild->rchild=(tree_node *)malloc(sizeof(tree_node));
	H->rchild->rchild->data=7;
	H->rchild->rchild->lchild==NULL;
	H->rchild->rchild->rchild==NULL;

	return H;
}

void printnode(tree_node *H)
{
	printf(" <%d> ",H->data);
}

void allprint(tree_node *H)
{
	if(H!=NULL)
	{

		allprint(H->lchild);
		printnode(H);
		allprint(H->rchild);
	}
	else
	{
		return;
	}

}

